<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script type="text/javascript">
		window.onload=function(){
			var btn=document.getElementById("btn");
			btn.onclick=function(){
				var xmlHttpRequest=new XMLHttpRequest();
				
				xmlHttpRequest.open("post","${pageContext.request.contextPath}/xxx",true);
				xmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				xmlHttpRequest.send("username=asdf&password=adsf"); 
				
				xmlHttpRequest.open("get","${pageContext.request.contextPath}/xxx",true);
				xmlHttpRequest.send(null);
				xmlHttpRequest.onreadystatechange=function(){
					if(xmlHttpRequest.readyState==4 && xmlHttpRequest.status==200){
						var text=xmlHttpRequest.responseText;
						var h1=document.getElementById("h1");
						h1.innerHTML=text;
					}
				};
			};
		};	
	
	</script>
</body>
</html>